﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace PerCiGal.DAL
{
	public class DALHelper
	{
	    private const string Suffix = "PerCiGal.DAL.SQLScript.";

	    public DALHelper()
		{

		}

		public static string GetConnectionString(string filePath)
		{
			return "Data Source=" + filePath + ";Max Database Size=4090;";
		}

		public static string GetsqlCommandText(string name)
		{
		    try
			{
				Assembly assembly = Assembly.GetExecutingAssembly();

			    string result = null;

			    using (var textStreamReader = new StreamReader(assembly.GetManifestResourceStream(Suffix + name)))
				{
					result = textStreamReader.ReadToEnd();
				}

				if (string.IsNullOrEmpty(result)) throw new ArgumentNullException(name);

				return result;
			}
			catch (Exception exc)
			{
				throw exc;
			}
		}

		public static string[] GETSQLCommandList(string name)
		{
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();

                string result = null;

                using (var textStreamReader = new StreamReader(assembly.GetManifestResourceStream(Suffix + name)))
                {
                    result = textStreamReader.ReadToEnd();
                }

                if (string.IsNullOrEmpty(result)) throw new ArgumentNullException(name);

                return result.Split(';');
            }
            catch (Exception exc)
            {
                throw exc;
            }
		}
	}
}
